Quick usage examples for PyDisdrometer

This notebook shows some (very) brief examples of current PyDisdrometer functionality and how to interact with it.

NASA GV Field Campaign Parsivel Format

Let's start with a NASA Ground Validation Parsivel formatted file.


In [16]:
%pylab inline

import pydisdrometer


Populating the interactive namespace from numpy and matplotlib

In [17]:
filename = '../testdata/IFloodS_APU01_2013_0502_dsd.txt' #Parsivel 05, March 2nd

In [18]:
dsd = pydisdrometer.read_parsivel_nasa_gv(filename)

So at this point we have the drop size distribution read in. NASA strips out rainfall information though and I have not yet re-added the calculation for that(Maybe today or tomorrow). Let's do some T-Matrix scattering though. This should take a little bit(up to a minute or so on my laptop depending on the file).


In [19]:
dsd.calculate_radar_parameters()  #Ignore the warnings, we don't do QC first so sometimes doing scattering on zero drops causes complaints.

This assumes BC shape relationship, X band, 10C. You can pass in a new wavelength to change that. Let's plot some of the parameters, and then try to do something with the data.


In [20]:
plt.figure(figsize=(12,12))

plt.subplot(2,2,1)
plt.plot(dsd.time/60.0, dsd.fields['Zh']['data'])
plt.xlabel('Time(hrs)')
plt.ylabel('Reflectivity(dBZ)')
plt.xlim(5,24)

plt.subplot(2,2,2)
plt.plot(dsd.time/60.0, dsd.fields['Zdr']['data'])
plt.xlabel('Time(hrs)')
plt.ylabel('Differential Reflectivity(dB)')
plt.xlim(5,24)

plt.subplot(2,2,3)
plt.plot(dsd.time/60.0, dsd.fields['Kdp']['data'])
plt.xlabel('Time(hrs)')
plt.ylabel('Specific Differential Phase(deg/km)')
plt.xlim(5,24)

plt.subplot(2,2,4)
plt.pcolor(dsd.time/60.0, dsd.diameter, np.log10(dsd.Nd.T), vmin=0, vmax=6)
plt.xlabel('Time(hrs)')
plt.ylabel('Diameter')
plt.colorbar()
plt.ylim(0,5) #Zoom in some
plt.xlim(5,24)

plt.show()


Let's take what might be another common use case. Finding areas with certain size drops. In this case everything above 4mm. There are a few ways to do this but let's just create an indicator function for now.


In [21]:
plot(dsd.time/60.0 , 0<sum(dsd.Nd[:,dsd.diameter>4], axis=1))
plt.xlim(5,24)


Out[21]:
(5, 24)

Or maybe we just want a listing of the time steps where there are drops greater than 4mm


In [22]:
time_hrs = dsd.time/60.0
print(time_hrs[0<sum(dsd.Nd[:,dsd.diameter>4], axis=1)])


[ 10.05        10.06666667  19.31666667  19.65        19.66666667
  19.71666667  19.73333333  19.75        19.76666667  19.8         19.81666667
  19.83333333  19.86666667  19.9         19.98333333  20.01666667
  20.03333333  20.05        20.06666667  20.08333333  20.1         20.11666667
  20.13333333  20.26666667  20.28333333  20.36666667  20.4         20.43333333
  20.46666667  20.51666667  20.66666667  20.73333333  20.78333333
  20.81666667  20.83333333  20.9         20.93333333  20.96666667
  20.98333333  21.01666667  21.11666667  21.15        21.16666667  21.2
  21.21666667  21.25        21.26666667  21.31666667  21.36666667
  22.01666667  22.23333333  22.28333333  22.58333333  22.65        22.66666667
  22.73333333  22.8         22.81666667  22.85        22.95        23.03333333
  23.18333333  23.28333333  23.36666667  23.5       ]

In [22]: